package com.jsgt.greekfire.dao.viewmodel

import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import com.jsgt.greekfire.dao.AppDatabase
import com.jsgt.greekfire.dao.dao.AddressDao
import com.jsgt.greekfire.dao.model.ContactAddress

class AddressViewModel(application: Application) : AndroidViewModel(application) {
    private var addressDao: AddressDao? = null

    init {
        addressDao = AppDatabase.getInstance(application).addressDao()
    }


    fun getAllAddress(): LiveData<List<ContactAddress>>? {
        return addressDao?.get()
    }

    fun add(address: ContactAddress) {
        addressDao?.add(address)
    }

    fun delete(id: Int) {
        addressDao?.delete(id)
    }
}